import React,{Component} from 'react'
import { Modal,Button } from 'antd'

interface IProps {
    title:string,
    content:any,
    visible:boolean,
    width?:string,
    onOk?:() => void,
    onCancel?: () => void
}
interface IStates {
}

export default class ModalM extends Component<IProps,IStates> {
   public renderFooter = () => {
       if(this.props.onOk){
           return (
            [<Button type="default" key="cnacel" onClick={this.props.onCancel}>取消</Button>,
            <Button key="ok" type="primary" onClick={this.props.onOk}>确定</Button>]
           )
       }else {
           return null
       }
   }
    public renderModal(){
        const {title,content,onOk,onCancel,visible,width} = this.props
        return (
           <Modal
           title={title}
           visible={visible}
           width={width}
           onOk={onOk}
           onCancel={onCancel}
           footer={this.renderFooter()}
           >
               {content}
           </Modal>
        )
    }
    public render() {
        return (
            <React.Fragment>
                {this.renderModal()}
            </React.Fragment>
        )
    }
}